/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pe.edu.unmsm.cinfo.siga.datos;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author alumno
 */
@Entity
@Table(name = "MODULO")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Modulo.findAll", query = "SELECT m FROM Modulo m"),
    @NamedQuery(name = "Modulo.findByModCod", query = "SELECT m FROM Modulo m WHERE m.modCod = :modCod"),
    @NamedQuery(name = "Modulo.findByModNom", query = "SELECT m FROM Modulo m WHERE m.modNom = :modNom"),
    @NamedQuery(name = "Modulo.findByModDesc", query = "SELECT m FROM Modulo m WHERE m.modDesc = :modDesc"),
    @NamedQuery(name = "Modulo.findByModDura", query = "SELECT m FROM Modulo m WHERE m.modDura = :modDura"),
    @NamedQuery(name = "Modulo.findByModEst", query = "SELECT m FROM Modulo m WHERE m.modEst = :modEst"),
    @NamedQuery(name = "Modulo.findByModRec", query = "SELECT m FROM Modulo m WHERE m.modRec = :modRec"),
    @NamedQuery(name = "Modulo.findByModMaxcuota", query = "SELECT m FROM Modulo m WHERE m.modMaxcuota = :modMaxcuota"),
    @NamedQuery(name = "Modulo.findByModNmin", query = "SELECT m FROM Modulo m WHERE m.modNmin = :modNmin"),
    @NamedQuery(name = "Modulo.findByModImpresion", query = "SELECT m FROM Modulo m WHERE m.modImpresion = :modImpresion"),
    @NamedQuery(name = "Modulo.findByModCostoProf", query = "SELECT m FROM Modulo m WHERE m.modCostoProf = :modCostoProf"),
    @NamedQuery(name = "Modulo.findByModImpresionProg", query = "SELECT m FROM Modulo m WHERE m.modImpresionProg = :modImpresionProg")})
public class Modulo implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @GeneratedValue(generator="moduloCodGen")
    @SequenceGenerator(name="moduloCodGen", sequenceName="MODULO_COD_GEN", allocationSize=1)
    @Column(name = "MOD_COD")
    private Integer modCod;
    @Basic(optional = false)
    @Column(name = "MOD_NOM")
    private String modNom;
    @Column(name = "MOD_DESC")
    private String modDesc;
    @Column(name = "MOD_DURA")
    private Integer modDura;
    @Column(name = "MOD_EST")
    private Short modEst;
    @Column(name = "MOD_REC")
    private Short modRec;
    @Column(name = "MOD_MAXCUOTA")
    private Short modMaxcuota;
    @Column(name = "MOD_NMIN")
    private Short modNmin;
    @Column(name = "MOD_IMPRESION")
    private String modImpresion;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Column(name = "MOD_COSTO_PROF")
    private Double modCostoProf;
    @Column(name = "MOD_IMPRESION_PROG")
    private String modImpresionProg;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "modulo", fetch = FetchType.LAZY)
    private List<ProgramaModulo> programaModuloList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "modCod", fetch = FetchType.LAZY)
    private List<ModuloGrupo> moduloGrupoList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "modulo", fetch = FetchType.LAZY)
    private List<Precio> precioList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "modulo", fetch = FetchType.LAZY)
    private List<ModuloCurso> moduloCursoList;
    @Transient
    private PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);

    public Modulo() {
        this.modNom = "";
        this.modDesc = "";
        this.modEst = 1;
        this.modNmin = 0;
        this.modMaxcuota = 0;
        this.modRec = 0;
    }

    public Modulo(Integer modCod) {
        this();
        this.modCod = modCod;
    }

    public Modulo(Integer modCod, String modNom) {
        this();
        this.modCod = modCod;
        this.modNom = modNom;
    }

    public Integer getModCod() {
        return modCod;
    }

    public void setModCod(Integer modCod) {
        Integer old = this.modCod;
        this.modCod = modCod;
        changeSupport.firePropertyChange("modCod", old, modCod);
    }

    public String getModNom() {
        return modNom;
    }

    public void setModNom(String modNom) {
        String old = this.modNom;
        this.modNom = modNom;
        changeSupport.firePropertyChange("modNom", old, modNom);
    }

    public String getModDesc() {
        return modDesc;
    }

    public void setModDesc(String modDesc) {
        String old = this.modDesc;
        this.modDesc = modDesc;
        changeSupport.firePropertyChange("modDesc", old, modDesc);
    }

    public Integer getModDura() {
        return modDura;
    }

    public void setModDura(Integer modDura) {
        Integer old = this.modDura;
        this.modDura = modDura;
        changeSupport.firePropertyChange("modDura", old, modDura);
    }

    public Short getModEst() {
        return modEst;
    }

    public void setModEst(Short modEst) {
        Short old = this.modEst;
        this.modEst = modEst;
        changeSupport.firePropertyChange("modEst", old, modEst);
    }

    public Short getModRec() {
        return modRec;
    }

    public void setModRec(Short modRec) {
        Short old = this.modRec;
        this.modRec = modRec;
        changeSupport.firePropertyChange("modRec", old, modRec);
    }

    public Short getModMaxcuota() {
        return modMaxcuota;
    }

    public void setModMaxcuota(Short modMaxcuota) {
        Short old = this.modMaxcuota;
        this.modMaxcuota = modMaxcuota;
        changeSupport.firePropertyChange("modMaxcuota", old, modMaxcuota);
    }

    public Short getModNmin() {
        return modNmin;
    }

    public void setModNmin(Short modNmin) {
        Short old = this.modNmin;
        this.modNmin = modNmin;
        changeSupport.firePropertyChange("modNmin", old, modNmin);
    }

    public String getModImpresion() {
        return modImpresion;
    }

    public void setModImpresion(String modImpresion) {
        String old = this.modImpresion;
        this.modImpresion = modImpresion;
        changeSupport.firePropertyChange("modImpresion", old, modImpresion);
    }

    public Double getModCostoProf() {
        return modCostoProf;
    }

    public void setModCostoProf(Double modCostoProf) {
        Double old = this.modCostoProf;
        this.modCostoProf = modCostoProf;
        changeSupport.firePropertyChange("modCostoProf", old, modCostoProf);
    }

    public String getModImpresionProg() {
        return modImpresionProg;
    }

    public void setModImpresionProg(String modImpresionProg) {
        String old = this.modImpresionProg;
        this.modImpresionProg = modImpresionProg;
        changeSupport.firePropertyChange("modImpresionProg", old, modImpresionProg);
    }

    @XmlTransient
    public List<ProgramaModulo> getProgramaModuloList() {
        return programaModuloList;
    }

    public void setProgramaModuloList(List<ProgramaModulo> programaModuloList) {
        this.programaModuloList = programaModuloList;
    }

    @XmlTransient
    public List<ModuloGrupo> getModuloGrupoList() {
        return moduloGrupoList;
    }

    public void setModuloGrupoList(List<ModuloGrupo> moduloGrupoList) {
        this.moduloGrupoList = moduloGrupoList;
    }

    @XmlTransient
    public List<Precio> getPrecioList() {
        return precioList;
    }

    public void setPrecioList(List<Precio> precioList) {
        this.precioList = precioList;
    }

    @XmlTransient
    public List<ModuloCurso> getModuloCursoList() {
        return moduloCursoList;
    }

    public void setModuloCursoList(List<ModuloCurso> moduloCursoList) {
        this.moduloCursoList = moduloCursoList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (modCod != null ? modCod.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Modulo)) {
            return false;
        }
        Modulo other = (Modulo) object;
        if ((this.modCod == null && other.modCod != null) || (this.modCod != null && !this.modCod.equals(other.modCod))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "pe.edu.unmsm.cinfo.siga.datos.Modulo[ modCod=" + modCod + " ]";
    }
    
    public void addPropertyChangeListener(PropertyChangeListener l){
        changeSupport.addPropertyChangeListener(l);
    }
    
    public void removePropertyChangeListener(PropertyChangeListener l){
        changeSupport.removePropertyChangeListener(l);
    }
    
}
